#include<bits/stdc++.h>

using namespace std;


int main() {
    vector<int> v = {1, 2, 2, 2, 4, 3, 4};
    sort(v.begin(), v.end());
    for (auto e:v) {
        cout << e << " ";
    }
    cout << endl;
    auto pos = unique(v.begin(), v.end());//unique使用前必须数组有序
    cout << distance(v.begin(), pos) << endl;
    v.erase(pos, v.end());//重复的尾部元素都删除

    for (auto e:v) {
        cout << e << " ";
    }
    cout << endl;

}